package reduce.fz.com.reduce.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.TypeReference;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.abstracts.AbResponseListener;
import reduce.fz.com.reduce.abstracts.inter.PagerRequest;
import reduce.fz.com.reduce.adapter.StoryDetailAdapter;
import reduce.fz.com.reduce.bean.StoryCard;
import reduce.fz.com.reduce.bean.page.Pagination;
import reduce.fz.com.reduce.bean.result.Result;
import reduce.fz.com.reduce.fragment.base.BaseFragment;
import reduce.fz.com.reduce.init.RecycleOper;
import reduce.fz.com.reduce.service.StoryService;
import reduce.fz.com.reduce.util.HttpUtils;
import reduce.fz.com.reduce.util.JsonUtil;

/**
 * 分享故事详情Detail
 */
public class ShareDetailFragment extends BaseFragment implements View.OnClickListener {
    //故事分享详情
    private RecyclerView mStoryDetailListView;
    //赞
    private TextView mTvZan;
    //分享
    private TextView mTvShare;

    private Long storyid;
    //评论
    private TextView mTvComment;
    //上下文
    private Context context;
    //分页
    private Pagination pagination;

    private StoryService storyService;

    private StoryDetailAdapter detailAdapter;



    /**
     * 创建实体类
     *
     * @param
     * @return
     */
    public static ShareDetailFragment create(Long storyid) {
        Bundle bundle = new Bundle();
        bundle.putLong("storyid", storyid);
        ShareDetailFragment fragment = new ShareDetailFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    public ShareDetailFragment() {
        //接受传输并转换成对象
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_share_detail, container, false);
    }

    /**
     * 初始化组件信息
     *
     * @param view
     */
    public void initWidget(View view) {
        mStoryDetailListView = (RecyclerView) view.findViewById(R.id.story_detail_listview);
        RecycleOper oper = new RecycleOper(context, mStoryDetailListView);
        detailAdapter=new StoryDetailAdapter(context);
        mStoryDetailListView.setAdapter(detailAdapter);
        //mTvZan = (TextView) view.findViewById(R.id.ll_share_zan);
        mTvShare = (TextView) view.findViewById(R.id.tv_share);
        mTvComment = (TextView) view.findViewById(R.id.tv_comment);

    }
    /**
     * 初始化监听
     */
    public void initLinstener() {
        mTvZan.setOnClickListener(this);
        mTvShare.setOnClickListener(this);
        mTvComment.setOnClickListener(this);
    }

    /**
     * 监听触发
     *
     * @param v
     */
    @Override
    public void onClick(View v) {/*
        switch (v.getId()) {
            case R.id.ll_share_zan:
                operZan();
                break;
            case R.id.ll_share_fenxiang:
                operFenxiang();
                break;
            case R.id.ll_share_coment:
                forwardCommentList();
                break;
            default:
                break;
        }*/
    }
    /**
     * 赞的操作
     */
    public void operZan() {

    }

    /**
     * 分享操作
     */
    public void operFenxiang() {

    }

    /**
     * 进入评论列表
     */
    public void forwardCommentList() {

    }


    public void requestPagerUrl() {/*
        storyService.loadStoryCard(storyid, pagination, new AbResponseListener<StoryCard>(new TypeReference<Result<StoryCard>>(){}) {
            @Override
            public void responseInfo(Result<StoryCard> data) {
                detailAdapter.initData(data.getData());
            }
        });
*/

    }
}

